home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / lib / tk / button.tcl next >
Text File  |  1995-07-21  |  3KB  |  86 lines

  1. # button.tcl --
  2. #
  3. # This file contains Tcl procedures used to manage Tk buttons.
  4. #
  5. # $Header: /user6/ouster/wish/library/RCS/button.tcl,v 1.9 93/07/01 13:41:53 ouster Exp $ SPRITE (Berkeley)
  6. #
  7. # Copyright (c) 1992-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27.  
  28. # The procedure below is invoked when the mouse pointer enters a
  29. # button widget.  It records the button we're in and changes the
  30. # state of the button to active unless the button is disabled.
  31.  
  32. proc tk_butEnter w {
  33.     global tk_priv tk_strictMotif
  34.     if {[lindex [$w config -state] 4] != "disabled"} {
  35.     if {!$tk_strictMotif} {
  36.         $w config -state active
  37.     }
  38.     set tk_priv(window) $w
  39.     }
  40. }
  41.  
  42. # The procedure below is invoked when the mouse pointer leaves a
  43. # button widget.  It changes the state of the button back to
  44. # inactive.
  45.  
  46. proc tk_butLeave w {
  47.     global tk_priv tk_strictMotif
  48.     if {[lindex [$w config -state] 4] != "disabled"} {
  49.     if {!$tk_strictMotif} {
  50.         $w config -state normal
  51.     }
  52.     }
  53.     set tk_priv(window) ""
  54. }
  55.  
  56. # The procedure below is invoked when the mouse button is pressed in
  57. # a button/radiobutton/checkbutton widget.  It records information
  58. # (a) to indicate that the mouse is in the button, and
  59. # (b) to save the button's relief so it can be restored later.
  60.  
  61. proc tk_butDown w {
  62.     global tk_priv
  63.     set tk_priv(relief) [lindex [$w config -relief] 4]
  64.     set tk_priv(buttonWindow) $w
  65.     if {[lindex [$w config -state] 4] != "disabled"} {
  66.     $w config -relief sunken
  67.     }
  68. }
  69.  
  70. # The procedure below is invoked when the mouse button is released
  71. # for a button/radiobutton/checkbutton widget.  It restores the
  72. # button's relief and invokes the command as long as the mouse
  73. # hasn't left the button.
  74.  
  75. proc tk_butUp w {
  76.     global tk_priv
  77.     if {$w == $tk_priv(buttonWindow)} {
  78.     $w config -relief $tk_priv(relief)
  79.     if {($w == $tk_priv(window))
  80.         && ([lindex [$w config -state] 4] != "disabled")} {
  81.         uplevel #0 [list $w invoke]
  82.     }
  83.     set tk_priv(buttonWindow) ""
  84.     }
  85. }
  86.